package com.rigsofrods.truckeditor.gui;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JFrame;
import javax.swing.JLabel;

public class DialogAbout extends Dialog implements ActionListener{
	private static final long serialVersionUID = -5276418046476332015L;
	
	private JLabel label1;
	private Button okButton;
	private static final String text = 
			"<html><p>RoR Truck Editor<br> Work in progress...</p>" +
			"<p>Camera controls:<br>" + 
			"Orbit...		Ctrl + LMB<br>" +
			"Pan...			Shift + LMB<br>" + 
			"Zoom...		Ctrl + Shift + LMB<br></p></html>";

	public DialogAbout(JFrame owner, Boolean modal) {
		super(owner, "About", modal);


		GridBagLayout gridBagLayout;
		gridBagLayout = new GridBagLayout( );
		setLayout(gridBagLayout);
		setVisible(false);
		//setSize(350,400);
		setLocationRelativeTo(owner);
		setResizable(false);

		label1 = new JLabel(text, Label.LEFT);
		GridBagConstraints gbc;
		gbc = new GridBagConstraints( );
		gbc.gridx = 1;
		gbc.gridy = 1;
		gbc.fill = GridBagConstraints.NONE;
		gbc.insets = new Insets(40,30,30,30);
		((GridBagLayout)getLayout( )).setConstraints(label1, gbc);
		add(label1);

		okButton = new Button( );
		okButton.setLabel("OK");
		okButton.addActionListener(this);
		gbc = new GridBagConstraints( );
		gbc.gridx = 1;
		gbc.gridy = 2;
		gbc.fill = GridBagConstraints.NONE;
		gbc.insets = new Insets(10,10,10,10);
		((GridBagLayout)getLayout( )).setConstraints(okButton, gbc);
		add(okButton);
		pack();

	}

	@Override
	public void setVisible(boolean b)
	{
		if(b) 
		{ 
			Dimension bounds  = 
				Toolkit.getDefaultToolkit( ).getScreenSize( );
			Dimension abounds = getSize( ); 
			setLocation((bounds.width - abounds.width) / 2, 
					(bounds.height - abounds.height) / 3); 
		} 
		super.setVisible(b);
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		setVisible(false);
	}

}
